package com.songtech.shiro;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.songtech.auth.user.model.User;
import com.songtech.base.listener.SysSessionContext;

public class SessionUser {

	/**
	 * 获取登录用户
	 * @param request
	 * @return
	 */
	public static User getSessionUser(String token){
		HttpSession session = SysSessionContext.getSession(token);
		User user = null;
		if(session != null){
			user = (User) session.getAttribute(token);
		}
		return user;
	}
	
	public static User getSessionUser(HttpServletRequest request){
		String token = request.getParameter("_token");
		HttpSession session = SysSessionContext.getSession(token);
		User user = null;
		if(session != null){
			user = (User) session.getAttribute(token);
		}
		return user;
	}
}
